<template>
  <div>
    <ul>
      <li
        v-for="item in goodsList"
        :key="item.id"
        @click="ProductDetail(item.id)"
      >
        <img v-lazy="item.list_pic_url" alt="" width="100%"> 
        <div class="van-ellipsis">{{ item.name }}</div>
        <div class="price">{{ item.retail_price | RMBformat}}</div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
 
    };
  },
  methods:{
    ProductDetail(val){
      this.$router.push('/productDetail?id='+val)
      
      //修改详情页中相关产品不跳转 BUG
      //deBUG方法刷新路由

      //方法1.通过路由判断是否刷新页面
      // if(this.$route.path==='/searchpopup'){
      //   window.scrollTo(0, 0);
      //   this.$router.go(0)
      // }
      if(this.$route.path==='/productDetail'){
        

         window.scrollTo(0, 0);


         this.$router.go(0)
      }
      //方法2.设置定时器
      
      // setTimeout(()=>{
      //   this.$router.go(0)
      // },10)
    }
  },
  props:['goodsList']
};
</script>
 
<style lang = "less" scoped>
ul {
  padding: 0.1rem 1%;
  display: flex;
  flex-wrap: wrap;
  background-color: #fff;
  li {
    width: 45%;
    padding-left: 0.1rem;
    padding-right: 0.1rem;
    text-align: center;
    img {
      width: 100%;
    }
  }
}
</style>